package java;

public class Question26 {
    public static void main(String[] args) {
        int[] arr = {0,1,1,2,2,3,3,5};
        System.out.println(removeDuplicates(arr));
    }

    public static int removeDuplicates(int[] nums) {
        if (nums == null || nums.length < 1){
            return 0;
        }
        int index = 0;
        for (int i = 0; i < nums.length ; i ++){
            if (i - 1 >= 0 && nums[i] != nums[i - 1]){
                index ++;
                nums[index] = nums[i];
            }
        }
        return index + 1;
    }
}
